package com.wtc.stringbuffer;

import java.util.Scanner;

/**
 * @author 马可
 * @version 1.0
 * 练习题
 * 2023/5/19
 * IntelliJ IDEA
 */
public class StringBufferExercise {
    public static void main(String[] args) {
        StringBuffer stringBuffer = new StringBuffer("手机：");
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入手机价格：");et+
        double sc = scanner.nextDouble();
        StringBuffer stringBuffer1 = new StringBuffer(String.valueOf(sc));
        System.out.println(stringBuffer1.indexOf("."));
        int a = stringBuffer1.indexOf(".");
        if (a - 1 >= 3) {
            stringBuffer1.insert(a - 3, ",");
            while (true) {
                if (stringBuffer1.indexOf(",") - 1 >= 3) {
                    stringBuffer1.insert(stringBuffer1.indexOf(",") - 3, ",");
                } else {
                    break;
                }
            }
        }
        stringBuffer.append(stringBuffer1);
        System.out.println(stringBuffer);
    }
}
